'use strict';
scenes.main = function() {
	let cameraMoveObject = new CameraMoveObject(main.camera);
	cvs.on('resize', e => netmap.size.set(cvs.size));
	
	
	let onInput = e => dataInput.data.value = inputEl.value;
	let inputEl = document.querySelector('.input');
	inputEl.addEventListener('input', onInput);
	
	
	function listenersV(em) {
		em._stdin.on('assign', v => em.data.value = v);
		em.data.on('assign', v => em._stdout.value = v);
	};
	
	let dataInput = new nodes.DataNode(inputEl.value);
	listenersV(dataInput);
	
	
	let panels = [];
	panels.push(new nodes.PanelViewNode({
		data: 'Panel One',
		pos: vec2(100, 100),
		size: vec2(210, 120)
	}));
	
	panels.push(new nodes.PanelViewNode({
		data: 'Panel Two',
		pos: vec2(400, 100),
		size: vec2(210, 150)
	}));
	
	let activeEdit = null;
	for(let i = 0; i < panels.length; i++) listenersV(panels[i].data);
	
//	panels[1].data.stdin = panels[0].data.stdout;
	
	
	this.updata = function(dt) {
		let touchC = main.camera.buf(touch);
	//=======prePROCES=======//--vs--//=======EVENTS=======//
		cameraMoveObject.updata(touch, main.camera);
	//==================================================//
	
	
	//=======PROCES=======//--vs--//=======UPDATA=======//
		for(let i = 0; i < panels.length; i++) {
			if(touch.isTouchEventBox(panels[i])) {
				if(activeEdit !== null) {
					panels[activeEdit].data.stdin = '';
					panels[activeEdit].color = '#eeeeee';
				};
				
				inputEl.value = panels[i].data.data.value;
				onInput();
				panels[i].data.stdin = dataInput.data;
				panels[i].color = '#99ff99';
				
				activeEdit = i;
			};
		};
	//==================================================//
	
	
	//==========DRAW==========//--vs--//==========RENDER==========//
		main.ctx.clearRect(0, 0, cvs.width, cvs.height);
		netmap.draw(main);
		
		for(let i = 0; i < panels.length; i++) panels[i].draw(main);
	};	//==============================//
};